package com.yxuan.springboot.controller;

import com.yxuan.springboot.model.Comment;
import com.yxuan.springboot.service.CommentService;
import com.yxuan.springboot.util.CodeUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * 
 * @author zchao
 *   Comment控制器
 * @date 2023-05-14 20:40:39
 */
@Slf4j
@Controller
@Api(tags = "文章评论表")
@RequestMapping(value = "/comment", method = {RequestMethod.POST,RequestMethod.GET})
public class CommentController extends BaseController<Comment>{

    @Autowired
    protected CommentService commentService;

    @ApiOperation(value = "查询文章评论", notes = "根据文章Id,查询文章的评论",httpMethod = "GET")
    @ApiImplicitParams({@ApiImplicitParam(name = "information", value = "文章id",required = true, dataType = "String", paramType = "query")})
    @GetMapping("/queryComment")
    @ResponseBody
    public Map<String, Object> queryComment (String information){
        try{
            log.info("");
            //查询文章评论
            List<Comment> queryCommentList = commentService.queryComment(information);
            return ResponseMap(CodeUtil.Susser,null,queryCommentList);
        }catch (Exception e){
            log.error(e.getMessage());
            return ResponseMap(CodeUtil.Error,e.getMessage(),null);
        }
    }
	

}
